package com.das.mechanic_base.widget;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.greenrobot.greendao.converter.PropertyConverter;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * 作者：zhanglei on 2019/11/16 10:38
 * <p>
 * 邮箱：916256628@qq.com
 */
public class X3IntegerConverter implements PropertyConverter<List<Long>, String> {
    Gson mGson = new Gson();

    @Override
    public List<Long> convertToEntityProperty(String databaseValue) {
        Type type = new TypeToken<ArrayList<Long>>() {
        }.getType();
        ArrayList<Long> list = mGson.fromJson(databaseValue, type);
        return list;

    }

    @Override
    public String convertToDatabaseValue(List<Long> entityProperty) {
        String dbString = mGson.toJson(entityProperty);
        return dbString;
    }
}
